<?php

$dbhost = "mysql.groovemechanic.net";
$dbuser = "oproto_user";
$dbpass = "oproto12345";
$dbname = "groovemechanic_oproto";

$con = mysql_connect ($dbhost, $dbuser, $dbpass) or die(mysql_error());
mysql_select_db ($dbname) or die (mysql_error());

$docname = $_POST['name'];

$username = trim($_POST['username']);
if ($username == "") {
	$username = "NoName";
}

$query = "SELECT * FROM documents WHERE name = '$docname' AND username='$username'";
$result = mysql_query($query) or die(mysql_error());

if (mysql_num_rows($result) > 0) {
	$row = mysql_fetch_array($result);
	
	echo ( "{\"id\":".$row[id].", \"name\":\"".$row[name]."\", \"username\":\"".$row[username]."\", \"author\":\"".$row[author]."\", \"title\":\"".
			$row[title]."\", \"description\":\"".$row[description]."\", \"json\":".$row[json].
			", \"js\":\"".$row[js]."\", \"cssClasses\":\"".$row[cssclasses]."\"}");
	
} else {
	
	
	
}

mysql_close($con);

?>
